import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import User from '../views/User.vue'
import Main from '../views/Main.vue'
import Mall from '../views/Mall.vue'
import PageOne from '../views/PageOne.vue'
import PageTwo from '../views/PageTwo.vue'
Vue.use(VueRouter)

const routes = [
    { 
        path: '/', 
        component: Main,
        redirect: '/home',  //重定向  路径为 / 时跳转到 home 页面
        children: [
            { 
                name: 'home',
                path: '/home', 
                component: Home    //首页
            },
            { 
                name: 'user',
                path: '/user', 
                component: User    //用户管理 
            },
            { 
                name: 'mall',
                path: '/mall', 
                component: Mall   //商品管理
            },
            { 
                name: 'page1',
                path: '/page1', 
                component: PageOne   //页面1
            },
            { 
                name: 'page2',
                path: '/page2', 
                component: PageTwo   //页面二
            }
        ] 
    },

]


const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
})


export default router
